﻿using System.Web.Mvc;
using N2.Web;
using N2.Web.Mvc;
using Dinamico.Models;

namespace Shop.Cms.Controllers
{
    /// <summary>
    /// This controller returns a view that displays the item created via the management interface
    /// </summary>
    [Controls(typeof(RedirectToFirstChildModel))]
    public class RedirectToFirstChildController : ContentController<RedirectToFirstChildModel>
    {
        public override ActionResult Index()
        {

            if (!string.IsNullOrEmpty(CurrentItem.RedirectUrl))
            {
                return Redirect(CurrentItem.RedirectUrl);
            }
            else {
                return View(CurrentItem);
            }
        }

    }
}
